﻿using Global;
using Global.Helper;
using System.Reflection;
using System.Web.Helpers;

namespace Entity
{
    public class User : BaseEntity
    {
        public string LogonName { get; set; }
        public string NickName { get; set; }
        public string Password { get; set; }
        public string InviteCode { get; set; }
        public int? InvitedById { get; set; }
        public virtual User InvitedBy { get; set; }
        public virtual Contact Contact { get; set; }
        public void Register()
        {
            //始终在数据库中存有一个昵称，简化转换
            NickName = LogonName ?? Const.Nameless;
            SetInviteCode();
        }
        public void SetInviteCode()
        {
            InviteCode = RandomGenerator.GetNumbers(4);
        }

    }
}